home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue43 / tooltips / Hints3U.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-01-25  |  2.3 KB  |  90 lines

  1. { Tricky to get DBGrid display text for an arbitrary row }
  2. { Indicator and titles muck up dbgrid coordinate logic }
  3.  
  4. unit Hints3U;
  5. {$ifdef Ver80} { Delphi 1.0x }
  6.   {$define DelphiLessThan3}
  7. {$endif}
  8. {$ifdef Ver90} { Delphi 2.0x }
  9.   {$define DelphiLessThan3}
  10. {$endif}
  11. {$ifdef Ver93} { C++ Builder 1.0x }
  12.   {$define DelphiLessThan3}
  13. {$endif}
  14.  
  15. interface
  16.  
  17. uses
  18.   WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  19.   Dialogs, Db, DBTables, DBGrids, DBHntGrd, Grids, HintGrid, StdCtrls,
  20.   HintList;
  21.  
  22. type
  23.   TForm1 = class(TForm)
  24.     HSG: THintStringGrid;
  25.     HintDBGrid1: THintDBGrid;
  26.     Table1: TTable;
  27.     DataSource1: TDataSource;
  28.     Table1CustNo: TFloatField;
  29.     Table1Company: TStringField;
  30.     Table1Addr1: TStringField;
  31.     Table1Addr2: TStringField;
  32.     Table1City: TStringField;
  33.     Table1State: TStringField;
  34.     Table1Zip: TStringField;
  35.     Table1Country: TStringField;
  36.     Table1Phone: TStringField;
  37.     Table1FAX: TStringField;
  38.     Table1TaxRate: TFloatField;
  39.     Table1Contact: TStringField;
  40.     Table1LastInvoiceDate: TDateTimeField;
  41.     HintListBox1: THintListBox;
  42.     chkTitles: TCheckBox;
  43.     chkIndicator: TCheckBox;
  44.     procedure FormCreate(Sender: TObject);
  45.     procedure chkTitlesClick(Sender: TObject);
  46.     procedure chkIndicatorClick(Sender: TObject);
  47.   private
  48.   public
  49.     { Public declarations }
  50.   end;
  51.  
  52. var
  53.   Form1: TForm1;
  54.  
  55. implementation
  56.  
  57. {$R *.DFM}
  58.  
  59. { Give string grids some values }
  60. procedure TForm1.FormCreate(Sender: TObject);
  61. var
  62.   Loop, Loop2: Integer;
  63. const
  64.   Text = 'The quick brown fox jumps over a lazy dog';
  65. begin
  66.   for Loop := 1 to HSG.RowCount-1 do
  67.     for Loop2 := 1 to HSG.ColCount-1 do
  68.       HSG.Cells[Loop2, Loop] := Format('(%d, %d)', [Loop2, Loop]);
  69.   for Loop := Length(Text) downto 1 do
  70.     HintListBox1.Items.Add(Copy(Text, 1, Loop))
  71. end;
  72.  
  73. procedure TForm1.chkTitlesClick(Sender: TObject);
  74. begin
  75.   if chkTitles.Checked then
  76.     HintDBGrid1.Options := HintDBGrid1.Options + [dgTitles]
  77.   else
  78.     HintDBGrid1.Options := HintDBGrid1.Options - [dgTitles]
  79. end;
  80.  
  81. procedure TForm1.chkIndicatorClick(Sender: TObject);
  82. begin
  83.   if chkIndicator.Checked then
  84.     HintDBGrid1.Options := HintDBGrid1.Options + [dgIndicator]
  85.   else
  86.     HintDBGrid1.Options := HintDBGrid1.Options - [dgIndicator]
  87. end;
  88.  
  89. end.
  90.